/*
Jeeps wrapper for Garmin serial protocol.
- Copyright (C) 2002 Robert Lipe, robertlipe@usa.net
+ Copyright (C) 2002, 2003, 2004 Robert Lipe, robertlipe@usa.net
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
static GPS_PWay *cur_tx_routelist_entry;
static GPS_PTrack *tx_tracklist;
static GPS_PTrack *cur_tx_tracklist_entry;
+static char *getposn;
+static char *poweroff;
+
+static
+arglist_t garmin_args[] = {
+ { "get_posn", &getposn, "Return current position as a waypoint", ARGTYPE_BOOL},
+ { "power_off", &poweroff, "Command unit to power itself down", ARGTYPE_BOOL},
+ { 0, 0, 0, 0}
+};
static void
rw_init(const char *fname)
}
GPS_Enable_Error();
+ if (poweroff) {
+ GPS_Command_Off(fname);
+ return;
+ }
+
if (GPS_Init(fname) < 0) {
fatal(MYNAME ":Can't init %s\n", fname);
}
int i,n;
GPS_PWay *way;
+ if (getposn) {
+ waypoint *wpt = waypt_new();
+ wpt->latitude = gps_save_lat;
+ wpt->longitude = gps_save_lon;
+ wpt->shortname = "Position";
+ waypt_add(wpt);
+ return;
+ }
+
if ((n = GPS_Command_Get_Waypoint(portname, &way)) < 0) {
fatal(MYNAME ":Can't get waypoint from %s\n", portname);
}
static void
data_read(void)
{
+ if (poweroff) {
+ return;
+ }
+
switch(global_opts.objective) {
case trkdata:
track_read();
static void
data_write()
{
+ if (poweroff) {
+ return;
+ }
switch(global_opts.objective) {
case wptdata:
waypoint_write();
rw_deinit,
data_read,
data_write,
- NULL
+ garmin_args
};
GPS_PPacket tra;
GPS_PPacket rec;
+ GPS_Util_Little();
+
if(!GPS_Serial_On(port, &fd))
return gps_errno;
return MEMORY_ERROR;
GPS_Util_Put_Short(data,COMMAND_ID[gps_device_command].Cmnd_Turn_Off_Pwr);
-
- GPS_Make_Packet(&tra, LINK_ID[gps_link_type].Pid_Command_Data,
+
+ /* robertl - LINK_ID isn't set yet. Hardcode it to Garmin spec value */
+ GPS_Make_Packet(&tra, 10, /* LINK_ID[gps_link_type].Pid_Command_Data, */
data,2);
if(!GPS_Write_Packet(fd,tra))
return gps_errno;